@*
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
Layout = "_Layout";
}
<style>
	.lightbox{width:100%;z-index:100; height:100%;
	background-color:#666;
	-moz-opacity:0.2;
	opacity: 0.2; 
	position:absolute; top:0px; left:0px;}
	.xiamshi{
		z-index: 101;
		background-color:#fff;
		width: 350px;
		height: 150px;
		position:  absolute;
		top: 40%;
		left: 40%;
		padding-top: 30px;
	}
	.xiamshi button{

		position: relative;
margin-top: 60px;
margin-left: 180px;
	}
</style>



<body class="layui-anim layui-anim-up">
	<div class="x-nav">
		<span class="layui-breadcrumb">
			<a href="/Admin/Admin/Index">首页</a>
			<a>
				<cite>用户列表</cite>
			</a>
		</span>
		<a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);"
		 title="刷新">
			<i class="layui-icon" style="line-height:30px">ဂ</i>
		</a>
	</div>
	<div class="x-body">
		<xblock>
			<div class="layui-inline">
				<input type="text" placeholder="请输入用户名或手机号" autocomplete="off" class="layui-input search_input">

			</div>
            <button class="layui-btn search_btn" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
		</xblock>
		<table class="layui-table" lay-data="{ url:'/Admin/User/GetUser', page:true, id:'user'}" lay-filter="user">
			<thead>
				<tr>
					<th lay-data="{field:'', width:'7%', sort: true,type:'numbers'}">ID</th>
					<th lay-data="{field:'UserName', width:'15%'}">用户</th>
					<th lay-data="{field:'Mobile', width:'13%'}">状态</th>
					<th lay-data="{field:'Head', width:'50%', templet: '#head'}">图片地址</th>
					<th lay-data="{field:'' , width:'15%' , templet: '#barDemo'}">操作</th>
				</tr>
			</thead>
		</table>

		<script type="text/html" id="head">
			<a href="{{d.Head}}" target="_blank">{{d.Head}}</a>
        </script>

		<script type="text/html" id="barDemo">
			{{#  if(d.RealId>0){ }}

            <a class="layui-btn layui-btn-xs" lay-event="shenhe">审核</a>
            {{# } }}
            <a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="tuijian">设为掌门人</a>
            @*<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>*@
        </script>
	</div>

	<div class="lightbox" style="display:none;"></div>

	<div class="xiamshi" style="display:none;">
		<div class="layui-inline">
			<label class="layui-form-label">中文版</label>
			<div class="layui-input-inline">
				<input type="text" class="layui-input" id="test1" placeholder="yyyy-MM-dd">
			</div>
		</div>
		<button class="layui-btn layui-btn-sm j-queding">确定</button>
		<button class="layui-btn layui-btn-warm layui-btn-sm j-quxiao">取消</button>
	</div>





	<script>
		layui.use(['laydate', 'table', 'form', 'layer'], function() {
			var table = layui.table;
			var laydate = layui.laydate;

			//常规用法
			laydate.render({
				elem: '#test1'
			});

			$(".j-quxiao").click(function() {
				$(".xiamshi").hide();
				$(".lightbox").hide();
				$("#test1").val('');
			})

			//监听行工具事件
			table.on('tool(user)', function(obj) {
				var data = obj.data;
				//console.log(obj)
				if (obj.event === 'del') {
					layer.confirm('真的删除行么', function(index) {

						$.ajax({
							type: "post",
							url: "/Admin/Banner/Del",
							data: {
								id: data.Id
							},
							success: function(result) {
								if (result.state == "ok") {
									layer.msg(result.msg)
								} else {
									layer.msg(result.msg)
								}
							}
						})

						obj.del();

					});
				} else if (obj.event === 'shenhe') {
					HsCms.OpenPart(2, 'fdjkfjd', '/Admin/User/See?id=' + data.RealId, "审核", ['900px', '700px'], ['新增', '取消'],
						function(layero) {

						},
						function(index, layero) {
							$(".btnEdit", layero.find("iframe")[0].contentWindow.document).click();
						});
				} else if (obj.event === 'tuijian') {
					//页面层

					$(".xiamshi").show();
					$(".lightbox").show();
					$(".j-queding").click(function() {

						layer.confirm('真的设置该用户为掌门人吗', function(index) {
							$.ajax({
								type: "post",
								url: "/Admin/User/IsTuiJian",
								data: {
									id: data.Id,
									date: $("#test1").val()
								},
								success: function(result) {
									if (result.state == "ok") {
										$(".xiamshi").hide();
										$(".lightbox").hide();
										$("#test1").val('');
										layer.msg(result.msg)
									} else {
										layer.msg(result.msg)
									}
								}
							})


						});
					})
				}
			});

			var active = {
				reload: function() {
					//执行重载
					table.reload('user', {
						page: {
							curr: 1
						},
						where: {
							content: $.trim($(".search_input").val())
						}
					});
				}
			};
			$('.search_input').bind('keyup', function(event) {
				if (event.keyCode == "13") {
					var type = 'reload';
					active[type] ? active[type].call(this) : '';
				}
			});
			//查找
			$(".search_btn").click(function() {
				var type = 'reload';
				active[type] ? active[type].call(this) : '';
			});

		})
	</script>
</body>
